package com.example.gybicycle.controller.wx;

import com.example.gybicycle.common.Log.SysLoging;
import com.example.gybicycle.common.entity.NormalPage;
import com.example.gybicycle.common.entity.Result;

import com.example.gybicycle.common.util.LoginUtil;
import com.example.gybicycle.entity.LoginInfo;
import com.example.gybicycle.entity.SysCaption;
import com.example.gybicycle.service.InsureService;
import com.example.gybicycle.service.SysCaptionService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Tag(name = "说明")
@RestController
@RequestMapping("/wx/caption")
public class WxCaptionController {
    @Autowired
    private SysCaptionService captionService;
    @Autowired
    private InsureService insureService;
    @PostMapping("")
    @Operation(summary = "说明")
    public Result CyclingRule(@RequestBody SysCaption caption){
        if(caption.getType()==null)
            return Result.fail("请传入类型");
        if(caption.getType().equals(4)){
            String notice=insureService.getInsureNotice();
            caption.setContent(notice);
        }else
         caption=captionService.get(caption.getType());

        return Result.success(caption);
    }
    @PostMapping("/cyclingrule")
    @Operation(summary = "骑行须知")
    public Result CyclingRule( ){
        SysCaption caption=captionService.get(1);
        return Result.success(caption);
    }
    @PostMapping("/pricerule")
    @Operation(summary = "计价规则")
    public Result pricerule(){
        SysCaption caption=captionService.get(2);
        return Result.success(caption);
    }
    @PostMapping("/serve")
    @Operation(summary = "一键服务")
    public Result serve(){
        SysCaption caption=captionService.get(3);
        return Result.success(caption);
    }
    @PostMapping("/insureNotice")
    @Operation(summary = "投保需知")
    public Result<String> insureNotice(HttpServletRequest request){
        String notice=insureService.getInsureNotice();
        return Result.success(notice);
    }

}